package com.restaurant.application.indexes.accumulategoodslist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;
import com.restaurant.application.accumulategoods.support.GoodsData;

import java.util.List;
import java.util.stream.Collectors;

public class PcAccumulateShopPage implements PickableBean {

    public static final String FN_GOODSLIST = "goodsList";
    public static final String FN_ACCUMULATEPOINT = "accumulatePoint";
    public static final String FN_DOSEARCHPATH = "doSearchPath";
    public static final String FN_ADDGOODSPATH = "addGoodsPath";
    public static final String FN_ACCUMULATEPOINTS = "accumulatePoints";
    public static final String FN_ACCUMULATETYPE = "accumulateType";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_GOODSLIST,
             FN_ACCUMULATEPOINT,
             FN_DOSEARCHPATH,
             FN_ADDGOODSPATH,
             FN_ACCUMULATEPOINTS,
             FN_ACCUMULATETYPE);

    private List<GoodsData> goodsList;
    private Integer accumulatePoint;
    private String doSearchPath;
    private String addGoodsPath;
    private Integer accumulatePoints;
    private UID accumulateType;

    public PcAccumulateShopPage(List<GoodsData> goodsList, Integer accumulatePoint, String doSearchPath, String addGoodsPath, Integer accumulatePoints, UID accumulateType) {
        setGoodsList(goodsList);
        setAccumulatePoint(accumulatePoint);
        setDoSearchPath(doSearchPath);
        setAddGoodsPath(addGoodsPath);
        setAccumulatePoints(accumulatePoints);
        setAccumulateType(accumulateType);
    }

    public PcAccumulateShopPage() {
    }

    public PcAccumulateShopPage duplicate() {
        PcAccumulateShopPage result = new PcAccumulateShopPage();
        result.goodsList = this.goodsList == null ? null : this.goodsList.stream().map(e4->e4 == null ? null : e4.duplicate()).collect(Collectors.toList());
        result.accumulatePoint = this.accumulatePoint;
        result.doSearchPath = this.doSearchPath;
        result.addGoodsPath = this.addGoodsPath;
        result.accumulatePoints = this.accumulatePoints;
        result.accumulateType = this.accumulateType;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public List<GoodsData> getGoodsList() {
        if( goodsList == null) {
            goodsList = Lists.newArrayList();
        }
        return goodsList;
    }

    public void  setGoodsList(List<GoodsData> value) {
        this.goodsList = value;
    }

    public PcAccumulateShopPage withGoodsList(List<GoodsData> value) {
        setGoodsList(value);
        return this;
    }

    public PcAccumulateShopPage withGoodsList(List<GoodsData> value, List<GoodsData> defaultValue) {
        setGoodsList(value == null ? defaultValue : value);
        return this;
    }

    public PcAccumulateShopPage addGoodsList(GoodsData value) {
        if(goodsList == null) {
            goodsList = Lists.newArrayList();
        }
        this.goodsList.add(value);
        return this;
    }

    public Integer getAccumulatePoint() {
        return accumulatePoint;
    }

    public void  setAccumulatePoint(Integer value) {
        this.accumulatePoint = value;
    }

    public PcAccumulateShopPage withAccumulatePoint(Integer value) {
        setAccumulatePoint(value);
        return this;
    }

    public PcAccumulateShopPage withAccumulatePoint(Integer value, Integer defaultValue) {
        setAccumulatePoint(value == null ? defaultValue : value);
        return this;
    }

    public String getDoSearchPath() {
        return doSearchPath;
    }

    public void  setDoSearchPath(String value) {
        this.doSearchPath = value;
    }

    public PcAccumulateShopPage withDoSearchPath(String value) {
        setDoSearchPath(value);
        return this;
    }

    public PcAccumulateShopPage withDoSearchPath(String value, String defaultValue) {
        setDoSearchPath(value == null ? defaultValue : value);
        return this;
    }

    public String getAddGoodsPath() {
        return addGoodsPath;
    }

    public void  setAddGoodsPath(String value) {
        this.addGoodsPath = value;
    }

    public PcAccumulateShopPage withAddGoodsPath(String value) {
        setAddGoodsPath(value);
        return this;
    }

    public PcAccumulateShopPage withAddGoodsPath(String value, String defaultValue) {
        setAddGoodsPath(value == null ? defaultValue : value);
        return this;
    }

    public Integer getAccumulatePoints() {
        return accumulatePoints;
    }

    public void  setAccumulatePoints(Integer value) {
        this.accumulatePoints = value;
    }

    public PcAccumulateShopPage withAccumulatePoints(Integer value) {
        setAccumulatePoints(value);
        return this;
    }

    public PcAccumulateShopPage withAccumulatePoints(Integer value, Integer defaultValue) {
        setAccumulatePoints(value == null ? defaultValue : value);
        return this;
    }

    public UID getAccumulateType() {
        return accumulateType;
    }

    public void  setAccumulateType(UID value) {
        this.accumulateType = value;
    }

    public PcAccumulateShopPage withAccumulateType(UID value) {
        setAccumulateType(value);
        return this;
    }

    public PcAccumulateShopPage withAccumulateType(UID value, UID defaultValue) {
        setAccumulateType(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch(name) {
        case "goodsList": return getGoodsList();
        case "accumulatePoint": return getAccumulatePoint();
        case "doSearchPath": return getDoSearchPath();
        case "addGoodsPath": return getAddGoodsPath();
        case "accumulatePoints": return getAccumulatePoints();
        case "accumulateType": return getAccumulateType();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if(!(o instanceof PcAccumulateShopPage)) return false;
        return signature().equals(((PcAccumulateShopPage)o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean PcAccumulateShopPage has no signature defined, no hash code or equals possible.");
    }
}
